use std::fmt::{Display, Formatter};

#[derive(Debug)]
pub enum Error {
    IoError(std::io::Error),
    CustomError(String),
}

impl Display for Error {
    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
        let s = match self {
            Self::IoError(e) => e.to_string(),
            Self::CustomError(s) => s.to_string(),
        };
        fmt.write_str(&s)
    }
}

impl From<std::io::Error> for Error {
    fn from(e: std::io::Error) -> Self {
        Error::IoError(e)
    }
}
